#include "base\macros.h";
WAITINIT(artillerie);
private ["_target_pos","_kind","_cannons","_shooting_array","_side","_params","_pieces"];
_target_pos = _this select 0;
if (typename _target_pos == typename "") then {
	_target_pos = getMarkerPos _target_pos;
};
_kind = _this select 1;
_cannons = [];
if (count _this > 2) then { _cannons = _this select 2; };
_shooting_array = [];
if (count _this > 3) then { _shooting_array = _this select 3; };
_side = "";
if (count _this > 4) then { _side = _this select 4; };

if (typename _cannons == typename grpNull) then {
	_pieces = [];
	{
		if (_x isKindOf "StaticWeapon") then {
			if ((_pieces find _x) < 0) then {
				_pieces set [count _pieces, _x];
			};
		};
	} foreach (units _cannons);
	_cannons = _pieces;
};

_params = [_target_pos, _kind, _cannons];
if (count _shooting_array > 0) then {
	_params set [count _params, _shooting_array];
	if (_side != "") then {
		_params set [count _params, _side];
	};
};
_params spawn XfShootArti;